<?php 

class Form_Users_User extends App_Form_Backend {
	
	public function __construct($options, $editMode) {
		
		parent::__construct($options);
	}
	
	function init() {
		parent::init();
		
		$this->addElement('text', 'username', array(
			'label' => 'Nazwa użytkownika',
			'required' => true,
			'class' => 'text-input small-input'
		));
		
		$this->addElement('text', 'email', array(
			'label' => 'Email',
			'required' => true,
			'class' => 'text-input small-input'
		));
		
		$this->addElement('text', 'firstname', array(
			'label' => 'Imię',
			'required' => true,
			'class' => 'text-input small-input'
		));
		
		$this->addElement('text', 'lastname', array(
			'label' => 'Nazwisko',
			'required' => true,
			'class' => 'text-input small-input'
		));
		
		$this->addElement('password', 'password', array(
			'label' => 'Hasło',
			'class' => 'text-input small-input'
		));
		
		$this->addElement('password', 'passwordRepeat', array(
			'label' => 'Powtórz hasło',
			'class' => 'text-input small-input',
			'ignore'=> true
		));
		
		$this->addElement('checkbox', 'isActive', array(
			'label' => 'Aktywny'
		));
		
		$this->addElement('submit', 'submit', array(
			'label' => 'Zapisz',
			'ignore' => true,
			'class' => 'button'
		));
		
	}
	
	
	public function isValid($data) {
		
		if (!empty($_POST['password'])) {
			$this->getElement('passwordRepeat')->setRequired(true);
		}
		
		return parent::isValid($data);
	}
	
	public function createMode() {
		$this->getElement('password')->setRequired(true);
	}
}